package org.apache.lucene.store.entity;

import java.io.IOException;

import org.apache.lucene.store.IndexOutput;

import com.edocbase.entity.file.ChunkOutputStream;
import com.edocbase.entity.file.EntityFile;

public class EntityOutput extends IndexOutput {
	private EntityFile file = null;
	private ChunkOutputStream output;
	
	public EntityOutput(EntityFile file) {
		super();
		this.file = file;
		output = (ChunkOutputStream) file.getOutputStream();
	}

	@Override
	public void writeByte(byte b) throws IOException {
		output.write(new byte[]{b});
	}

	@Override
	public void writeBytes(byte[] b, int offset, int length) throws IOException {
		output.write(b, offset, length);
	}

	@Override
	public void flush() throws IOException {
		output.flush();
	}

	@Override
	public void close() throws IOException {
		output.close();
	}

	@Override
	public long getFilePointer() {
		return output.getFilePointer();
	}

	@Override
	public void seek(long pos) throws IOException {
		output.seek(pos);
	}

	@Override
	public long length() throws IOException {
		return file.getLength();
	}

}
